<%--
    Document   : myprofile
    Created on : Apr 27, 2011, 3:22:32 PM
    Author     : Kevin
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.movie.*" import="com.assg2.dao.*" %>
<%@include file="header.html"%>
<jsp:useBean id="ListMovies" scope="session" class="com.assg2.dao.DaoMovie" />
<% Movie movie = (Movie) request.getAttribute("resultmovie");
    DaoMovie daomovie = new DaoMovie();
    if (movie == null) {
        movie = (Movie) daomovie.findById(Integer.parseInt(request.getParameter("movieid")));
    }
    ArrayList nick = (ArrayList) request.getAttribute("nick");
    ArrayList comment = (ArrayList) request.getAttribute("comment");
    ArrayList date = (ArrayList) request.getAttribute("date");
    ArrayList actor = (ArrayList) request.getAttribute("actor");
    String usertype = (String) session.getAttribute("usertype");
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Movie Page</title>
    </head>
    <body>
        <h3><%=movie.getTitle()%></h3>
    <center>
        <iframe title="YouTube video player" class="youtube-player" type="text/html" 
                width="640" height="390" src="http://www.youtube.com/embed/<%=movie.getVideo()%>"
                frameborder="0" allowFullScreen></iframe>
    </center>
    <b> Lead actors:</b>
    <%for (int i = 0; i < actor.size(); i++) {%>
    <%=actor.get(i)%>&nbsp;&nbsp;&nbsp;&nbsp;
    <%}%>
    <br>
    <b>Duration: </b><%=movie.getDuration()%>minutes
    <br>
    <b>Rating: </b><%=movie.getAgerating()%>
    <br>
    <b>Director: </b> <%=movie.getDirector()%>
    <br>
    <b>Sypnosis: </b> <%=movie.getSynopsis()%>
    <br>
    <b>Rating: </b> <%=daomovie.movierating(movie.getIdmovie())%>

    <br>
    <%if (movie.getPoster() != null) {%>
    <CENTER><img width="500px" src="images/posters/<%=movie.getPoster()%>" /></CENTER>
    <br>
    <br>
    <br>
    <br>
    <%}%>   
    <br>
    <% if (session.getAttribute("user") != null) {
            out.println("<a href='dispatcher?operation=book&movieid=" + movie.getIdmovie() + "'>Book</a><br>");
        }%>
    <b>Comment: </b>
    <br>
    <br>
    <br>
    <% for (int i = 0; i < nick.size(); i++) {%>
    Comment No.<%=i + 1%><br>
    <%=nick.get(i)%>&nbsp;&nbsp;said:<br>
    <%=comment.get(i)%><br>
    on:<%=date.get(i)%>
    <br>
    <br>
    <br>
    <%}%>
    <%if (movie.Showing()) {%>

    <br>

    <% if (session.getAttribute("user") == null) {%>
    You can post your review and rate this movie after <a href="dispatcher?operation=login">login</a>.<br>

    <%} else if (usertype.matches("viewer")) {%>

    <b>Rating: </b> click the star to post the review:
    <br>
    <p>&nbsp;</p>
    <%=daomovie.starreviews(movie.getIdmovie())%> 
    <br>
    Recommend this <a href="dispatcher?operation=recommend&movieid=<%=Integer.toString(movie.getIdmovie())%>">movie</a>
    <%}%> 
    <%}%>
    <%if ((session.getAttribute("user") != null) && (usertype.matches("owner"))) {%>
    <% session.setAttribute("movieaddshow", movie);%>
    <a href="dispatcher?operation=addshow">Add showtime for this movie</a>
    <%}%> 
</body>
</html>
<%@include file="footer.html"%>
